package com.rui.sideup.test.udpinfo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class MyTherad extends Thread {

    private Socket accept;

    public MyTherad(Socket socket) {
        this.accept = socket;
    }

    @Override
    public void run() {
        // 把低级流转换高级流
        try {
            BufferedReader buff = new BufferedReader(new InputStreamReader(accept.getInputStream()));
            String msg;
            while ((msg = buff.readLine()) != null) {
                // 打印了
                System.out.println(accept.getRemoteSocketAddress() + "说了：" + msg);
            }

        } catch (IOException e) {
            System.out.println(accept.getRemoteSocketAddress() + "离线啦！！！");
        }
    }
}
